<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8"/>
    <meta http-equiv="expires" content="0">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store"/>
    <link rel="stylesheet" href="/static/css/element-ui.css">
    <title></title>
    <link rel="Shortcut Icon" href="/static/img/favicon.ico"/>
    <style type="text/css">
        body {
            width: 100%;
            height: 95%;
            background: #303a49;
        }
        [v-cloak] {
            display: none;
        }
        .form{
            margin-top: 150px;
        }
    </style>
</head>


<body>
<div id="app" class="login" v-cloak>
    <el-row>
        <el-col :span="6" :offset="9">
            <el-form class="form" label-width="50px"  >
                <el-form-item label="" prop="" style="text-align: center;color: #fff;">
                    <span style="font-size: 28px;">信息管理系统</span>
                </el-form-item>
                <el-form-item label="" prop="account">
                    <el-input placeholder="账号"
                            prefix-icon="el-icon-info" v-model="bean.account"></el-input>
                </el-form-item>
                <el-form-item label="" prop="password">
                    <el-input placeholder="密码" type="password"
                              prefix-icon="el-icon-menu" v-model="bean.password"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button style="width: 100%" type="primary" @click="login()">登录
                    </el-button>
                </el-form-item>
            </el-form>

        </el-col>
    </el-row>
</div>
</body>
</html>
<template id="templates"></template>
<!--第三方开源框架-->
<script src="../js/jquery-3.2.1.min.js"></script>
<script src="../js/vue.js"></script>
<script src="../js/vue-router.js"></script>
<script src="/static/js/element-ui.js"></script>
<script src="../js/moment.js"></script>
<script src="../js/layer/layer.js"></script>
<!--基础js 共享 全局变量 和全局方法-->
<script src="../js/solar.js?v=0309"></script>
<!--配置应用-->
<script src="../js/adminConfig.js?v=0309"></script>
<!--首页vue启动js-->
<script>
    const app = new Vue({
        el: "#app",
        router: router,
        data: {
            openModuleName: "nrgl",
            activeName: "",
            bean: {},
            showLoginView: false,
            mobileCodeLogin: false,
        },
        methods: {
            chcekLogin: function () {
                var isLogin = true;
                var _this = this;
                $.ajax({
                    type: "get",
                    url: baseHost + "/isLogin?t=u",
                    async: false,
                    success: function (data) {
                        if (data.code == 200) {
                            if (data.body&&data.body.role == 4) {
                                location = "index.html?v=180228";
                            } else {
                                location = "admin.html?v=180228";
                            }
                        }
                    }
                });
                return isLogin;
            },
            login: function () {
                var _this = this;
                $.ajax({
                    type: "post",
                    url: baseHost + "/login",
                    data: this.bean,
                    async: false,
                    success: function (data) {
                        if (data.code == 200) {
                            layer.alert("登录成功!", {icon: 6}, function (index) {
                                layer.close(index);
                                _this.showLoginView = false;
                            });
                            setAjaxHeader("token", data.msg);
                            localStorage.token = data.msg;
                            localStorage.account = _this.bean.account;
                            document.cookie = "token=" + data.msg + ";path=/";
                            location.reload();
                        } else {
                            layer.alert(data.msg, {icon: 5}, function (index) {
                                layer.close(index);
                            });
                        }
                    }
                });
            },
        },
        mounted: function () {
            this.chcekLogin();
        }
    });
    //app.$mount('#app')


</script>

